package edu.washington.ling.syntric.io;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;

public class Example {
	private String id;
	private String original;
	private String gloss;
	private String translation;
	private Set<String> metaData;
	private Map<String, TreeRepresentation> treeMap;
	private List<TreeRepresentation> systemTrees;
	
	public Example(String id) {
		this.id = id;
		original = null;
		gloss = null;
		translation = null;
		metaData = new HashSet<String>();
		treeMap = new HashMap<String, TreeRepresentation>();
		systemTrees = new LinkedList<TreeRepresentation>();
	}
	public Example(Example exr) {
		this.id = exr.getID();
		original = exr.getOriginal();
		gloss = exr.getGloss();
		translation = exr.getTranslation();
		metaData = exr.getMetaData();
		treeMap = new HashMap<String, TreeRepresentation>();
		systemTrees = new LinkedList<TreeRepresentation>();
	}
	public void setOriginal(String original) {
		this.original = original;
	}
	public void setGloss(String gloss) {
		this.gloss = gloss;
	}
	public void setTranslation(String translation) {
		this.translation = translation;
	}
	public boolean hasOriginal() {
		return this.original != null;
	}
	public boolean hasGloss() {
		return this.gloss != null;
	}
	public boolean hasTranslation() {
		return this.translation != null;
	}
	public String getID() {
		return id;
	}
	public String getOriginal() {
		return this.original;
	}
	public String getGloss() {
		return this.gloss;
	}
	public String getTranslation() {
		return this.translation;
	}
	public void addMetaData(String label) {
		metaData.add(label);
	}
	public Set<String> getMetaData() {
		return metaData;
	}
	public boolean hasMetaData(String label) {
		return metaData.contains(label);
	}
	public void addTreeRep(TreeRepresentation tr) {
		treeMap.put(tr.getLayer(), tr);
	}
	
	public boolean hasTreeRep(String layer) {
		return treeMap.containsKey(layer);
	}
	public TreeRepresentation getTreeRep(String layer) {
		return treeMap.get(layer);
	}
	public List<TreeRepresentation> getTreeReps() {
		return new LinkedList<TreeRepresentation>(treeMap.values());
	}
	public void addSystemTreeRep(TreeRepresentation tr) {
		systemTrees.add(tr);
	}
	public void setSystemTreeReps(List<TreeRepresentation> trs) {
		systemTrees = trs;
	}
	public boolean hasSystemTreeReps() {
		return systemTrees.size() > 0;
	}
	public List<TreeRepresentation> getSystemTreeReps() {
		return systemTrees;
	}
}
